// MegaDialogNvc.cpp : implementation file
//

#include "stdafx.h"
#include "../GUI/MegaDialogNvc.h"
#include "../GUI/MegaBitmap.h"
#include "resource.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMegaDialogNvc dialog
//

CMegaDialogNvc::CMegaDialogNvc(UINT id, CWnd* pParent, UINT uiSkinSingle, UINT uiSkinDouble, UINT uiSkinWide)
	: CDialog(id, pParent)
{
	m_pSkinSingle = new CMegaBitmap();
	m_pSkinDouble = new CMegaBitmap();
	m_pSkinWide = new CMegaBitmap();
	m_pSkinSingle->LoadBitmap(uiSkinSingle);
	m_pSkinDouble->LoadBitmap(uiSkinDouble);
	m_pSkinWide->LoadBitmap(uiSkinWide);

	m_nSize = 1;
	m_pBackgroundBmp = m_pSkinSingle;
}

CMegaDialogNvc::~CMegaDialogNvc()
{
	if(m_pSkinSingle)
		delete m_pSkinSingle;
	if(m_pSkinDouble)
		delete m_pSkinDouble;
	if(m_pSkinWide)
		delete m_pSkinWide;
}

void CMegaDialogNvc::AdjustRegion()
{
	CSize szBase = m_pBackgroundBmp->GetBitmapDimension();

	// enlarge main window
	// check if right-bottom edge is outside screen
	CRect rcWnd;
	GetWindowRect(&rcWnd);
	CRect rcClient;
	GetClientRect(&rcClient);

	SetWindowPos(NULL, rcWnd.left, rcWnd.top,
				 szBase.cx + (rcWnd.Width() - rcClient.Width()),
				 szBase.cy + (rcWnd.Height() - rcClient.Height()), SWP_NOZORDER);
}

BEGIN_MESSAGE_MAP(CMegaDialogNvc, CDialog)
	//{{AFX_MSG_MAP(CMegaDialogNvc)
	ON_WM_SYSCOMMAND()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMegaDialogNvc message handlers
void CMegaDialogNvc::OnSysCommand(UINT nID, LPARAM lParam)
{
	if(SC_CLOSE == nID)
		EndDialog(IDOK);
	else
		CDialog::OnSysCommand(nID, lParam);
}

void CMegaDialogNvc::OnOK()
{
// do nothing, just dont want dialog to finish
}

void CMegaDialogNvc::OnCancel()
{
// do nothing, just dont want dialog to finish
}

UINT CMegaDialogNvc::OnNcHitTest(CPoint point)
{
	return CDialog::OnNcHitTest(point);
}

BOOL CMegaDialogNvc::OnEraseBkgnd(CDC* pDC)
{
	CRect rc;
	GetClientRect(&rc);

	// background
	m_pBackgroundBmp->Draw(pDC, 0, 0);

	return 1;
}
